package com.ruoyi.project.system.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SmRefund;
import com.ruoyi.project.system.service.ISmRefundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 退款Controller
 */
@RestController
@RequestMapping("/system/refund")
public class SmRefundController extends BaseController {
    @Autowired
    private ISmRefundService smRefundService;

    /**
     * 查询退款列表
     */
    @PreAuthorize("@ss.hasPermi('system:refund:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmRefund smRefund) {
        startPage();
        List<SmRefund> list = smRefundService.selectSmRefundList(smRefund);
        return getDataTable(list);
    }

    /**
     * 获取退款详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:refund:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(smRefundService.selectSmRefundById(id));
    }

    /**
     * 删除退款
     */
    @PreAuthorize("@ss.hasPermi('system:refund:remove')")
    @Log(title = "退款", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(smRefundService.deleteSmRefundByIds(ids));
    }

}
